/**
 * 
 */
package bookshop.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author Administrator
 * 
 */
public class DBUtils {
	
    private static final DBUtils me = new DBUtils();

	private DBUtils() {

	}

	public static DBUtils getInstance() {
		return me;
	}

	public Connection getConn() {
		Connection con = null;
		try {
			Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
			con=DriverManager.getConnection("proxool.ddc-ds");
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return con;
	}

	public void releaseRes(Connection ct, PreparedStatement ps, ResultSet rs) {

		try {
			if (rs != null)  rs.close();
			if (ps != null) ps.close();
			if (ct!=null)    ct.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
